<?php
namespace app\logic\yuql;

use app\api\model\yuql\Article;
use app\Request;

class ArticleLogic{

    public static function index($keyword){
        $wheres = [];
        if (!empty($keyword) || isset($keyword)){
            $wheres[] = ['title','like','%'.$keyword.'%'];
        }
//        var_dump($keyword);die();
        $data=\app\api\model\yuql\Article::where($wheres)
            ->order('id','desc')
            ->paginate(5);
        return $data;

    }

    public static function create($array){

        $res = \app\api\model\yuql\Article::create($array);
        return $res;
    }

    public static function update($params){
        $res = Article::update($params);
        return $res;

    }

    public static function delete($id){

        $res = \app\api\model\yuql\Article::destroy($id);
        return $res;

    }

    public static function detail($id){

        $res = Article::find($id);
        return $res;
    }
}